android webview ZoomButtonsController 导致android.view.WindowLeaked 问题解决
Activity has leaked window android.widget.ZoomButtonsController that was originally added here android.view.WindowLeaked:
引起这个错误的原因是:
发现是webview的 ZoomButton,也就是那两个放大和缩小的按钮,导致的。如果设置为让他们出现,并且可以自动隐藏,那么,由于他们的自动隐藏是一个渐变的过程,所以在逐渐消失的过程中如果调用了父容器的destroy方法,就会导致Leaked。
所以解决方案是,在destroy之前,先让他俩立马消失。
解决方案:
方案一:在onDestroy方法中将整个WebView隐藏
1 | protected void onDestroy() { |
方案二:在finish或者onDestory中将所以View移除
1 | public void finish() { |
详细报错日志:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16E/WindowManager﹕ android.view.WindowLeaked: Activity WebActivity has leaked window android.widget.ZoomButtonsController$Container{24ca0f69 V.E..... ......I. 0,0-1080,146} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:370)
at com.android.org.chromium.android_webview.AwZoomControls.invokeZoomPicker(AwZoomControls.java:29)
at com.android.org.chromium.content.browser.ContentViewCore.onScrollBeginEventAck(ContentViewCore.java:1270)
at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5256)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)